﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraTreeList.Nodes;
using DevExpress.XtraTreeList;

namespace PRO_DOCS.DocumentManagementSystem.ADMIN.WIN.Configurations.Departments
{
    public partial class FolderStructureBuilder : BLL.WIN.Templates.DevxPermissionUserControlTemplate
    {
        DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE CURRENR_SELECTED_FOLDER_STRUCTURE
        {
            get;
            set;
        }

        DAL.Database.ARCHIVE_DEPARTMENT CURRENR_SELECTED_ARCHIVE_DEPARTMENT
        {
            get;
            set;
        }

        bool IS_FIRST_LOAD
        { get; set; }
        public FolderStructureBuilder()
        {
            InitializeComponent();
            IS_FIRST_LOAD = true;
            CURRENR_SELECTED_FOLDER_STRUCTURE = new DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE();
            CURRENR_SELECTED_ARCHIVE_DEPARTMENT = new DAL.Database.ARCHIVE_DEPARTMENT();

            List<DAL.Database.ARCHIVE_DEPARTMENT> sYSTEM_DEPARTMENTS = PRO_DOCSDatabaseDataContext.ARCHIVE_DEPARTMENTs.ToList();
            gridControl1.DataSource = sYSTEM_DEPARTMENTS;

        }
        private void btnDeleteFolder_Click(object sender, EventArgs e)
        {
            if (CURRENR_SELECTED_FOLDER_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID.Equals(0))
            {

            }
        }

        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (gridView1.FocusedRowHandle > -1)
            {
                PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENT aRCHIVE_DEPARTMENT = gridView1.GetFocusedRow() as PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENT;

                CURRENR_SELECTED_ARCHIVE_DEPARTMENT = (from dep in PRO_DOCSDatabaseDataContext.ARCHIVE_DEPARTMENTs
                                                       where dep.ARCHIVE_DEPARTMENT_ID.Equals(aRCHIVE_DEPARTMENT.ARCHIVE_DEPARTMENT_ID)
                                                       select dep).FirstOrDefault();

                ucFolderStructureTree1.BUILD_ARCHIVE_DEPARTMENT_FOLDER_STRUCTURE(CURRENR_SELECTED_ARCHIVE_DEPARTMENT);
            }
        }
    }
}
